<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div class="pop" id="pop" style="display: none">
        <div class="header">
            <h2>头</h2>
        </div>
        <div class="content">
            开源中国在线工具,ostools为开发设计人员提供在线工具,提供jsbin在线 CSS、JS 调试,在线 Java API文档,在线 PHP API文档,在线 Node.js API文档,Less CSS编译器,
        </div>
        <div class="buttons" id="btns">
            <a href="javascript:;">确定</a>
            <a href="javascript:;">取消</a>
        </div>
    </div>
    <input type="button" value="点我" id="btn1">
    <script>
        function popWindo(id,pop,fun1,fun2){
            var pop = document.getElementById(pop);
            pop.style.display = 'block';        //让整个层显示
            var btns = document.getElementById(id);
            var btn1 = btns.children[0];
            var btn2 = btns.children[1];

            try {
                if(typeof fun1 != 'function' || !(fun1 instanceof Function)){
                    throw new Error('你没有确定按钮的方法')
                }
                if(typeof fun2 != 'function' || !(fun2 instanceof Function)){
                    throw new Error('你没有确定按钮的方法')
                }
            } catch (e){
                throw '好像是这两个回调函数没有调用'
            }
            btn1.onclick = function(callback){
                return function(){
                    if(typeof callback == 'function' && callback instanceof Function){
                        callback()
                    } else {
                        console.log("a")
                    }
                }
            }(fun1)
            btn2.onclick = function(callback){
                return function(){
                    if(typeof callback == 'function' && callback instanceof Function){
                        callback();
                    }
                }
            }(fun2);
        }

        var btn1 = document.getElementById('btn1');
        btn1.onclick = function(){
            popWindo('btns','pop',function(){
                location.href = 'http://www.baidu.com'
            },function(){
                document.getElementById('pop').style.display = 'none';
            })
        }
    </script>



</body>
</html>